package com.dw.widget.slideshow.config;

import java.util.ArrayList;
import java.util.List;

import com.dw.widget.slideshow.config.view.HeaderView;
import com.dw.widget.slideshow.config.view.HeaderView.OnBackButtonClickListener;
import com.dw.widget.slideshow.config.view.list.ListBigIconSelectView;
import com.dw.widget.slideshow.config.view.list.ListBlockView;
import com.dw.widget.slideshow.R;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;

public class BaseBigIconSelectActivity extends Activity {

	protected Object[][] listItemData = null;
	
	protected HeaderView header;
	protected ListBlockView listBlock;
	protected Button bnOk;
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		
		super.onCreate(savedInstanceState);
		
		setContentView(R.layout.base_bigiconselect);
		findViewsById();
		initViews();
	}
	
	private void findViewsById()
	{
		header = (HeaderView)findViewById(R.id.basebigiconselect_header);
		listBlock = (ListBlockView)findViewById(R.id.basebigiconselect_block);
		bnOk = (Button)findViewById(R.id.basebigiconselect_bnOk);
	}
	
	protected void initViews()
	{
		header.setOnBackButtonClickListener(new OnBackButtonClickListener() {
			
			@Override
			public void onButtonClick(View v) {
				
				BaseBigIconSelectActivity.this.finish();
			}
		});
		
		if(listItemData == null)
		{
			return;
		}
		
		try
		{
			for(Object[] listRow : listItemData)
			{
				int iconRes = (Integer)listRow[0];
				String text = (String)listRow[1];
				boolean checked = ((Boolean)listRow[2]).booleanValue();
				
				ListBigIconSelectView listItem = (ListBigIconSelectView)getLayoutInflater().inflate(R.layout.listitem_bigiconselect, null);
				listItem.setIcon(iconRes);
				listItem.setText(text);
				listItem.getCheckBox().setChecked(checked);
				listItem.setBackgroundColor(0xFFEBEBEB);
				
				listBlock.addListItem(listItem);
			}
		}
		catch(Exception e)
		{
			e.printStackTrace();
		}
	}
	
}
